package com.itcast.hotel.listen;

import com.itcast.hotel.constant.MqConstants;
import com.itcast.hotel.service.HotelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.amqp.rabbit.annotation.RabbitListener;

/**
 * @author 29143
 */
@Component
@Slf4j
public class HotelListener {

    @Autowired
    HotelService hotelService;

    @RabbitListener(queues = MqConstants.HOTEL_INSERT_QUEUE)
    public void listenInsertMsg(Long hotelId){
        log.info("接收到 更新酒店消息通知  酒店id:{}",hotelId);
        hotelService.insertById(hotelId);
    }
    @RabbitListener(queues = MqConstants.HOTEL_DELETE_QUEUE)
    public void listenDeleteMsg(Long hotelId){
        log.info("接收到 删除酒店消息通知  酒店id:{}",hotelId);
        hotelService.deleteById(hotelId);
    }
}
